using Jurassic;

namespace Kiwi.Node.Utility
{
    public static class Parameter
    {
        public static string GetOptionalStringParameterValue(object parameter, string @default = null)
        {
            if ((parameter is Undefined) || (parameter is Null))
            {
                return @default;
            }
            var converted = TypeConverter.ToPrimitive(parameter, PrimitiveTypeHint.String);
            return converted == null ? @default : converted.ToString();
        }
    }
}